//备注：拷贝代码请加上作者信息
//作者：王海涛
//邮箱：1126471088@qq.com
//版本：V0.0.3
#ifndef __MCU_DISPLAY_DRIVER_H__
#define __MCU_DISPLAY_DRIVER_H__

#include "lcd_lm_driver.h"
#include "res_xpt2046.h"
#include "../../../BSP/FSMC_BSP/fsmc8080_bsp.h"
#include "../../../BSP/GPIO_BSP/gpio_bsp.h"
#include "../../../../Tool/Font/font.h"
#include "../../../../Tool/RGB_Convert/RGB_Convert.h"
#include "../../../Delay/delay.h"
#include <string.h>


/* 屏幕分辨率 MCU_1024x600  MCU_800x480 MCU_480x320 MCU_480x272 MCU_320x240*/
#define MCU_320x240


#if defined(MCU_1024x600)   // 1024x600配置
    #define MCU_PIXEL_WIDTH   1024 // 屏宽
    #define MCU_PIXEL_HEIGHT  600  // 屏高
#elif defined(MCU_800x480)  // 800x480配置
    #define MCU_PIXEL_WIDTH   800  // 屏宽
    #define MCU_PIXEL_HEIGHT  480  // 屏高
#elif defined(MCU_480x320)  // 480x320配置
    #define MCU_PIXEL_WIDTH   480  // 屏宽
    #define MCU_PIXEL_HEIGHT  320  // 屏高
#elif defined(MCU_480x272)  // 480x272配置
    #define MCU_PIXEL_WIDTH   480  // 屏宽
    #define MCU_PIXEL_HEIGHT  272  // 屏高
#elif defined(MCU_320x240)  // 320x240配置
    #define MCU_PIXEL_WIDTH   320  // 屏宽
    #define MCU_PIXEL_HEIGHT  240  // 屏高
#else
    #define MCU_PIXEL_WIDTH   800  // 屏宽
    #define MCU_PIXEL_HEIGHT  480  // 屏高
#endif


/*缓存大小设置*/
#define MCU_Display_Buffer_Size    (MCU_PIXEL_WIDTH * 1)

/*命令*/
typedef enum
{
    LCD_Read_Pixel = 0x0C,//读取像素格式
    LCD_Read_ID    = 0xD3,//读取ID
    LCD_Set_Pos_X  = 0x2A,//设置X轴
    LCD_Set_Pos_Y  = 0x2B,//设置Y轴
    LCD_Fill_Pixel = 0x2C,//填数据
}WHT_MCU_Display_Cmd_enum;

/*显示模式*/
typedef enum
{
    Display_Mode0 = 0x00,
    Display_Mode1 = 0x01,
    Display_Mode2 = 0x02,
    Display_Mode3 = 0x03,
    Display_Mode4 = 0x04,
    Display_Mode5 = 0x05,//标准横屏
    Display_Mode6 = 0x06,
    Display_Mode7 = 0x07,
}WHT_MCU_Display_Mode_enum;

/*屏幕参数*/
typedef struct
{
    const uint16_t X_Length;//屏幕x轴水平长度
    const uint16_t Y_Length;//屏幕y轴垂直长度
    WHT_Font_Info_t* Font;  //字体选择
    uint16_t New_Pos_X;     //最新x水平坐标
    uint16_t New_Pos_Y;     //最新y垂直坐标
    uint16_t BK_Color;      //字体背景色
    uint16_t Font_Color;    //字体颜色
}WHT_MCU_Display_Info_t;

typedef struct
{
    WHT_MCU_Display_Info_t* WHT_Info;                       //屏幕信息
    void (*WHT_Init)(void);                                 //初始化
    void (*WHT_Set_Display_Mode)(WHT_MCU_Display_Mode_enum display_mode);//设置扫描方向
    /*自带ASCII字体*/
    uint8_t(*WHT_Set_Font_Row)(uint16_t row, uint16_t pos_x);//指定字体显示在那行row最小0 pos_x最小0
    void (*WHT_Clear_Row)(uint8_t row);                      //清空某行字体
    void (*WHT_Puts)(const char* s);                         //ASCII字符显示
    /*颜色填充*/
    void (*WHT_Fill_Color_Buffer)(uint16_t sx, uint16_t sy, uint16_t ex, uint16_t ey, const uint16_t* intput_buf);//区域填充颜色
    void (*WHT_Get_Reg_Value)(uint16_t reg, uint16_t* output_buf, uint32_t count);//获取寄存器值
}WHT_MCU_Display_Driver_t;

extern const WHT_MCU_Display_Driver_t WHT_MCU_Display_Driver;

#endif /*__MCU_DISPLAY_DRIVER_H__*/
